let http = require("http");
let fs = require("fs");

let server = http.createServer();
server.on('request', (req, res)=> {
    console.log(req.url);
    res.setHeader("Content-Type", "text/html; charset=utf-8");
    if(req.url == '/index.html') {
        let buf = fs.readFileSync('./index.html');
        res.end(buf);
    }
    res.end('<a href="http://www.baidu.com">点击跳转至百度<a>');
})

server.listen(8080, ()=>{
    console.log('server running at http://127.0.0.1:8080');
})